<!DOCTYPE html>
<html>
	<head> 
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>设置</title>
		<link rel="stylesheet" href="__TMPL__Public/css/ui.css" />
		<link rel="stylesheet" href="__TMPL__Public/css/normalize.css" />
		<link rel="stylesheet" href="__TMPL__Public/css/main.css" />
		<link rel="stylesheet" href="__TMPL__Public/css/style.css" />
	</head>
	<body>
		<!--<div class="header">
			<a onclick="goBack()" class="left-arrow"><img src="__TMPL__Public/img/arrow-b.png"></a>
			设置
		</div>-->
		<div class="linebg">
			<a class="line-i ebb">
				<span class="line-before subscribe">消息通知</span>
				<span class="line-arrow">
					<div class="uibox">
			            <label class="ui-switch">
			                <input id="msgpush" onchange="msg(this)" type="checkbox" checked="checked">
			            </label>
					</div>
				</span>
			</a>
			<a class="line-i ebb">
				<span class="line-before subscribe">好友搜索</span>
				<span class="line-arrow">
		           <div class="uibox">
			            <label class="ui-switch">
			            	<if condition="$visible eq 1">
			            		<input onchange="friendchg(this)" type="checkbox" checked="checked">
			            		<else/>
			            		<input onchange="friendchg(this)" type="checkbox">
			            	</if>
			                
			            </label>
					</div>
				</span>
			</a>
			<a href="javascript:void(0)" onclick="clearcache()" class="line-i ebb">
				<span class="line-before subscribe">清空缓存</span>
				<span class="line-arrow light-f"><span id="cache">0.01M</span><img src="__TMPL__Public/img/user/arrow-r.png"></span>
			</a>
			<a id="update" href="javascript:void(0)" onclick="checkupdate()" class="line-i">
				<span class="line-before subscribe">版本更新</span>
				<span class="line-arrow light-f">v0.1<img src="__TMPL__Public/img/user/arrow-r.png"></span>
			</a>
		</div>
	</body>
	<script src="__TMPL__Public/js/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__TMPL__Public/js/main.js?{$version}"></script>
	<script type="text/javascript">
	$("#cache").text((Math.random()+"").substring(0,4)+"M");
	var pushvalue=null;
	toast.init();
	initmsg();
	var cache = $("#cache");
		function clearcache(){
			cache.text("0M");
		}
		function checkupdate(){
			$.post(
				"/HAction/update",
				{"version":"0.1"},function(data){
					toast.show(data.info);
				}
			);
		}
		function friendchg(obj){
			$.post(
				"/HAction/isvisible",{"val":obj.checked?1:2},
				function(data){
				}
			);
		}
		function initmsg(){
			pushvalue = localStorage.msgpush;
			console.log(pushvalue);
			if(pushvalue=="false"){
				console.log("trigger");
				$("#msgpush").trigger("click");
			}
		}
		function msg(obj){
			pushvalue = obj.checked;
			console.log(pushvalue);
			localStorage.msgpush = pushvalue;
			if(pushvalue==undefined||pushvalue==null)pushvalue=false;
			var ua = navigator.userAgent.toLowerCase();	
			if (ua.indexOf("iphone")>-1) {
				
			} else if (ua.indexOf("android")>-1) {
				window.ocm.notifyFlag(pushvalue);
			}
		}
		function cancelmsg(){
			$("#msgpush").attr("checked",false);
			$("#msgpush").prop("checked",false);
		}
		(function(){
			var ua = navigator.userAgent.toLowerCase();	
			if (ua.indexOf("iphone")>-1) {
				$("#update").hide();
			} else if (ua.indexOf("android")>-1) {
					
			}
		})();
		
	</script>
</html>
